package com.chen.base.utils;

/**
 * System工具类
 * @Author: ChenJinLong
 * @DateTime: 2023/8/24 11:42
 **/
public class SystemUtil {

    /**
     * 判断是否是linux环境
     * @return true-是
     */
    public static boolean isLinux() {
        return System.getProperty("os.name").toLowerCase().contains("linux");
    }

    /**
     * 判断是否是windows环境
     * @return true-是
     */
    public static boolean isWindows() {
        return System.getProperty("os.name").toLowerCase().contains("windows");
    }

    /**
     * 返回当前系统code
     * @return 系统code
     */
    public static String systemCode() {
        if (isLinux()) {
            return "linux";
        } else if (isWindows()) {
            return "windows";
        } else {
            return "other";
        }
    }

    /**
     * 判断是否是idea里面启动
     * @return true:是  false:否
     */
    public static Boolean isRunInIDEA() {
        try {
            Class.forName("com.intellij.rt.execution.application.AppMainV2");
            return true;
        } catch (ClassNotFoundException ignored) {
            return false;
        }
    }
}
